package com.myk.game.gobangchess.signs;

import com.myk.game.gobangchess.Sign;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * 线段标记
 */
public class LineSign extends Sign {

    private final int start; //开始的格子
    private final int end; //结束的格子
    private final String color; //颜色
    private final int style; //0:普通线条  1:单向箭头  2:双向箭头

    public LineSign(int start, int end, String color, int style) {
        this.start = start;
        this.end = end;
        this.color = color;
        this.style = style;
    }

    @Override
    public String getSignInfo() {
        return type + "," + start + "," + end + "," + color + "," + style;
    }

    public void serialize(DataOutputStream dos) throws IOException {
        dos.writeInt(this.start);
        dos.writeInt(this.end);
        dos.writeUTF(this.color);
        dos.writeInt(this.style);
    }

    public LineSign(DataInputStream dis) throws IOException {
        this.start = dis.readInt();
        this.end = dis.readInt();
        this.color = dis.readUTF();
        this.style = dis.readInt();
    }
}
